<?php if (!isset($_SESSION)) session_start(); ?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">

<title>Koreanet</title>

<!-- Nanum Webfont -->
<style>
* {
	font-family: 'NanumGothic' !important;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script>
 google.load( "webfont", "1" );
 google.setOnLoadCallback(function() {
  WebFont.load({ custom: {
   families: [ "NanumGothic" ],
   urls: [ "http://fontface.kr/NanumGothic/css" ]
  }});
 });
</script>

<!-- Bootstrap core CSS -->
<link href="./dist/css/bootstrap.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="./css/daily_report.css" rel="stylesheet">
<link rel="stylesheet"
	href="./lib/datetimepicker/bootstrap-datetimepicker.min.css" />
</head>

<body>
<?php include 'header.php';?>
<?php require_once './class/Evaluation.inc';?>
<?php require_once './class/Evaluation_check.inc';?>
<?php

if ($getType == 1) {
	if ($login == null || $login->getGrade () > 2) {
		echo "<script type='text/javascript'>";
		echo "location.replace('./main.php');";
		echo "</script>";
		exit ();
	}
}

$search_date = $_GET['date1'];

if($search_date == ""){
	$search_date = substr(date('Y/m/d'),0,4);
}

?>
	<div class="container container_bottom">
		<div class="row row_margin">
			<div class="col-md-12">
				<h2>인사평가 설정(평가일,수익률,성장률)</h2>
			</div>
		</div>
		<div class="row row_margin" style="margin-top:20px;">
			<div class="col-md-6">
				<div class="input-group-wrapper">
					<div class="input-group">
						<span class="input-group-addon">평가기준일</span>
						<select class="form-control" id="year_date">
							<?php
							for($i = 2014; $i <= 2020; $i++){
								echo "<option value='".$i."'>".$i."</option>";
							}	
							?>
						</select>
					</div>
				</div>
			</div>
		</div>
		<div class="row row_margin">
			<div class="col-md-6">
				<div class="input-group-wrapper">
					<div class="input-group">
						<span class="input-group-addon">평가기준일</span>
						<select class="form-control" id="day_date" onchange="date_change()">
							<option value="03/31">03/31</option>
							<option value="06/30">06/30</option>
							<option value="09/30">09/30</option>
							<option value="12/31">12/31</option>
						</select>
					</div>
				</div>
			</div>
		</div>
		<div class="row row_margin">
			<div class="col-md-6">
				<div class='input-group date' id='picker1'>
					<span class="input-group-addon">평가기간시작</span> <input id='sdate'
						name='sdate' type='text' class='form-control'
						placeholder='달력 버튼을 누르세요.' data-format='YYYY/MM/DD'
						readonly='readonly' value='<?php echo date("Y/m/d")?>' /> <span
						class='input-group-addon input-group-addon-end add-last'>
						<button class='btn btn-default btn-calendar'>달력</button>
					</span>
				</div>
			</div>
		</div>
		<div class="row row_margin">
			<div class="col-md-6">
				<div class='input-group date' id='picker2'>
					<span class="input-group-addon">평가기간종료</span> <input id='edate'
						name='edate' type='text' class='form-control'
						placeholder='달력 버튼을 누르세요.' data-format='YYYY/MM/DD'
						readonly='readonly' value='<?php echo date("Y/m/d")?>' /> <span
						class='input-group-addon input-group-addon-end add-last'>
						<button class='btn btn-default btn-calendar'>달력</button>
					</span>
				</div>
			</div>
		</div>
		<div class="row row_margin">
			<div class="col-md-6 text-right">
				<button class="btn btn-lg btn-default" type="button"
				onclick="javascript:initData()">저장</button>
			</div>
			
			<div class="col-md-6 button_align">
				<div class="row row_margin row_top" style="float:right;">
					<?php 
					if($login->getSession() == '100001'){?>
					<div class="btn-group">
						<button class="btn btn-lg btn-success" type="button"
							onclick="location.href='./evaluation_report.php?pageType=1'">평가조회</button>
					</div>
					<?php } ?>
				</div>
			</div>
		</div>
		
		<div class="row row_margin">
			<div class="col-md-4">
				<div id="search_date">
					<div class="input-group-wrapper first_wrapper">
						<div class='input-group date' id='picker0'>
							<span class='input-group-addon'>검색:날짜(년도)</span> <select
									class="form-control" id="date1" name="date1"
									onchange="javascript:changeDelemiter(this)">
									
									<?php 
										$eval_date = new Evaluation_check();
										$eval_date -> date_search('3',$login->getSession(),$search_date."/12/31");
										
									?>
								</select>
							</span>
						</div>
					</div>
				</div>
			</div>
		</div>
		<form class="form-signin" role="form"
			<?php
			if ($getType == null || empty ( $getType )) {
				echo "action='./ajax/modify_daily_report.php'";
			} else if ($getType == 1) {
				echo "action='./ajax/create_daily_report.php'";
			}
			?>
			method="post">
			<div class="row row_margin">
				<div class="col-md-12">
					<div class="row row_margin row_top">
						<table class="table table-bordered" id="attendance_table">
							<?php
								$eval = new Evaluation();
								$eval->search4table_setting("4",$search_date."/12/31",null);
							?>
						</table>
					</div>
				</div>
				<!-- 추가 부분 -->
			</div>
			<!--
			<div class="row row_margin">
				<div class="col-md-12 text-right">
					<button class="btn btn-lg btn-default" type="button"
						onclick="javascript:initData()">저장</button>
				</div>
			</div>
			-->
		</form>
	</div>
	<!-- /container -->

	<!-- Bootstrap core JavaScript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
	<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
	<script src="./dist/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="./lib/moment/moment.js"></script>
	<script type="text/javascript" src="./lib/moment/transition.js"></script>
	<script type="text/javascript" src="./lib/moment/collapse.js"></script>
	<script type="text/javascript"
		src="./lib/datetimepicker/bootstrap-datetimepicker.min.js"></script>

	<script type="text/javascript">
	$(window).load(function () {
		$('#picker1').datetimepicker({
			pickTime: false
		});
		$('#picker2').datetimepicker({
			pickTime: false
		});
	});

	$(document).ready(function () {
		$('#date1').val(<?php echo $search_date; ?>);
		$('#year_date').val(<?php echo $search_date; ?>);

		date_change();
	});
	function changeDelemiter(obj){
		location.href="./evaluation_setting.php?date1="+obj.value;
	}
	function date_change(){
		
		var date1 = $('#year_date').val();
		var date2 = $('#day_date').val();
		$('#sdate').val(date1+"/"+date2.substring(0,3)+"20");
		$('#edate').val(date1+"/"+date2);
	}
	function initData() {
		var date1 = $('#year_date').val();
		var date2 = $('#day_date').val();
		var sdate = $('#sdate').val();
		var edate = $('#edate').val();

		var work_time = date1+'/'+date2;

		var param = '';
		param = '?table=3&work_time='+work_time+'&rate1=&rate2=&sdate='+sdate+'&edate='+edate;
		location.href='./ajax/create_evaluation_rate.php'+param;
	}
	function eval_submit(type,arg){
		var rate1 = $('#rate1'+arg).val();
		var rate2 = $('#rate2'+arg).val();
		var work_time = $('#work_time'+arg).val();

		if(rate1 == '' || rate2 == ''){
			alert("수익률/성장률을 모두 입력하세요.");
			return false;
		}

		var param = '';
		param = '?table='+type+'&work_time='+work_time+'&rate1='+rate1+'&rate2='+rate2+'&sdate=&edate=';
		location.href='./ajax/create_evaluation_rate.php'+param;
		
	}
	function checkNumber(obj, isWon)
	{
		if (obj.value.length > 0)
		{
			for (var i = 0; i < obj.value.length; i++)
			{
				if (!(isWon && obj.value.charAt(i) == ',') && (obj.value.charAt(i) < '0' || obj.value.charAt(i) > '9')) {
					obj.value = obj.value.substr(0,i);
				}
			}
			if (isWon) {
				obj.value = commaNum(obj.value);
			}
		}
	}

	function commaNum(num) {
		num = num.replace(/,/gi,'');
		var len, point, str;
		num = num + "";
		point = num.length % 3;
		len = num.length;

		str = num.substring(0, point);
		while (point < len) {
			if (str != "") str += ",";
			str += num.substring(point, point + 3);
			point += 3;
		}
		return str;
	}
	</script>
</body>
</html>